/*
 * ReactionSystem.h
 *
 *  Created on: 23 Jul 2011
 *      Author: Allan
 */

#ifndef REACTIONSYSTEM_H_
#define REACTIONSYSTEM_H_

// C++ includes
#include <iostream>
#include <vector>
using namespace std;

// Eigen includes
#include <Eigen/Core>
using namespace Eigen;

// C++ includes
#include "Reaction.h"

class ReactionSystem
{
public:
	ReactionSystem();
	
	ReactionSystem(const vector<Reaction>& reactions);
	
	virtual ~ReactionSystem();
	
	const unsigned GetNumReactions() const;
	
	const unsigned GetNumSpecies() const;
	
	const vector<Reaction>& GetReactions() const;
	
	const vector<string>& GetSpecies() const;
	
	const vector<Index>& GetIndexes() const;
	
	const MatrixXd& GetStoichiometricMatrix() const;
	
	const MatrixXd AssembleStoichiometricMatrix(const vector<string>& species) const;
	
	const VectorXd EquilibriumConstants(double T, double P) const;
	
	const VectorXd ReactionQuotients(const VectorXd& a) const;
	
	const VectorXd KineticRates(double T, double P, const VectorXd& n, const VectorXd& a) const;
	
	const Reaction& operator[](unsigned idx) const;
	
private:
	/// The reactions that compose the reaction system
	vector<Reaction> reactions;
	
	/// The set of all species in the reactions
	vector<string> species;
	
	/// The indexes of all species in the reactions
	vector<Index> ispecies;
	
	/// The stoichiometric matrix of the reactions
	MatrixXd uri;
};

ostream& operator<<(ostream& out, const ReactionSystem& reactionSystem);

#endif /* REACTIONSYSTEM_H_ */

